<!doctype html>
<html lang="en" class="fixed">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <title>藏经阁</title>
    <!-- <link type="text/css" rel="stylesheet" href="../../topjui/plugins/layui/css/layui.css"> -->
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/layui/css/layui.css')) ?>" media="all">
    <link rel="stylesheet" type="text/css"
          href="<?php xcho(loadSource('/assets/plugins/bootstrap/css/bootstrap.min.css')) ?>">
    <link rel="stylesheet" type="text/css"
          href="<?php xcho(loadSource('/assets/plugins/bootstrap/css/bootstrap-datetimepicker.min.css')) ?>">
    <link rel="stylesheet" type="text/css"
          href="<?php xcho(loadSource('/assets/plugins/bootstrap/css/build_standalone.css')) ?>">
    <link rel="stylesheet" type="text/css" href="<?php xcho(loadSource('/assets/plugins/bootstrap/css/build.css')) ?>">
    <link type="text/css" href="<?php xcho(loadSource('/assets/plugins/font-awesome/css/font-awesome.min.css')) ?>" rel="stylesheet"/>
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/ztree/css/zTreeStyle/zTreeStyle.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/css/new_main.css')) ?>">
</head>
<body><?php include_once TPL_PATH . 'public/nav.phtml'; ?>
<div class="container-fluid">
    <div class="row">
        <form action="<?php xcho(url('/student/pool/index')) ?>" method="POST" accept-charset="utf-8"
              enctype="multipart/form-data">
            <div class="class-box">
                <div class="class-box-head">
                    <div class="class-box-title">
                        <h3 class="col-md-8">全部</h3>
                        <div class="input-group col-md-4">
                            <input type="text" class="form-control" placeholder="可搜索学员、联系手机" id="keyword"
                               name="keyword" value="<?php xcho($search['keyword']) ?>">
                            <span class="input-group-btn">
                                <input type="submit" class="btn btn-primary edit" value="搜索" />
                            </span>
                        </div> 
                    </div>
                </div>
                <div class="class-box-body">
                    <div class="col-xs-6 col-sm-3 form-container form-inline">
                        <div>
                            <label>意向状态：</label>
                            <div class="checkbox">
                                <?php foreach ($intention as $ik => $iv) { ?>
                                    <label class="checkbox-inline">
                                        <input type="checkbox" title="checkbox_intention"
                                               name="intention[]" <?php if (!empty($search['intention'])) {
                                            foreach ($search['intention'] as $in) {
                                                if ($in == $iv['dict_value']) { ?> checked="checked" <?php }
                                            }
                                        } ?>
                                               value="<?php xcho($iv['dict_value']) ?>"></input><?php xcho($iv['cn_name']) ?>
                                    </label>
                                <?php } ?>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-6 col-sm-3 form-container form-inline">

                        <div class="form-group">
                            <label>修改日期：</label>
                            <select name="datetp" class="form-control">
                                <option value="">全部</option>
                                <?php foreach ($dateType as $dk => $dV) { ?>
                                    <option value="<?php xcho($dV['dict_value']) ?>" <?php if ($search['datetp'] == $dV['dict_value']) { ?> selected="selected"<?php } ?> > <?php xcho($dV['cn_name']) ?></option>
                                <?php } ?>
                            </select>
                            <input size="16"
                                   type="text"  value="<?php xcho($search['begin_edit_time']) ?>"
                                   name="begin_edit_time" class="form-control begin_edit_time"
                                   placeholder="yy-mm-dd">

                            <input size="16" type="text"  value="<?php xcho($search['end_edit_time']) ?>" name="end_edit_time" class="form-control end_edit_time" placeholder="yy-mm-dd">
                        </div>
                        <div class="form-group">
                            <label>创建日期：</label>
                            <select name="add_time" class="form-control">
                                <option value="">全部</option>
                                <?php foreach ($dateType as $ak => $aV) { ?>
                                    <option value="<?php xcho($aV['dict_value']) ?>" <?php if ($search['add_time'] == $aV['dict_value']) { ?> selected="selected"<?php } ?> > <?php xcho($aV['cn_name']) ?></option>
                                <?php } ?>
                            </select>
                            <input size="26" type="text"  value="<?php xcho($search['begin_add_time']) ?>" name="begin_add_time" class="form-control begin_add_time" placeholder="yy-mm-dd">
                            <input size="26" type="text"  value="<?php xcho($search['end_add_time']) ?>" name="end_add_time" class="form-control end_add_time" placeholder="yy-mm-dd">
                        </div>
                    </div>
                    <div class="col-xs-6 col-sm-3 form-container form-inline">
<!--                        <div class="form-group">-->
<!--                            <label>渠道：</label>-->
<!--                            <select name="channel_id" class="form-control">-->
<!--                                <option value="-1">全部</option>-->
<!--                                --><?php //foreach ($channel as $cV) { ?>
<!--                                    <option value="--><?php //xcho($cV['id']) ?><!--" --><?php //if ($search['channel_id'] == $cV['id']) { ?><!--  selected="selected" --><?php //} ?><!-- > --><?php //xcho($cV['cn_name']) ?><!--</option>-->
<!--                                --><?php //} ?>
<!--                            </select>-->
<!--                        </div>-->

                        <div >
                            <?php if(!empty($channel)){ ?>
                            <a href="#" id="toggle">渠道展开</a>
                            <div id="content" style="display: none;">
                                <label>渠道：</label>
                                <label>全选：<input type="checkbox" id="channelAll"></label>
                                <div class="checkbox_channel">

                                    <?php foreach ($channel as  $cV) { ?>
                                        <label class="checkbox-inline">
                                            <input type="checkbox" title="checkbox_channel"
                                                   name="channel_id[]" <?php if (!empty($search['channel_id'])) {
                                                foreach ($search['channel_id'] as $in) {
                                                    if ($in == $cV['id']) { ?> checked="checked" <?php }
                                                }
                                            } ?>
                                                   value="<?php xcho($cV['id']) ?>"></input><?php xcho($cV['cn_name']) ?>
                                        </label>
                                    <?php } ?>
                                </div>

                                <?php } ?>
                        </div>

                        <div class="form-group">
                            <label>最新跟踪：</label>
                            <select name="last_follow_id" class="form-control">
                                <option value="">全部</option>
                                <?php foreach ($dateType as $fV) { ?>
                                    <option value="<?php xcho($fV['dict_value']) ?>" <?php if ($search['last_follow_id'] == $fV['dict_value']) { ?> selected="selected"<?php } ?> > <?php xcho($fV['cn_name']) ?></option>
                                <?php } ?>
                            </select>
                            <input size="16" type="text"  value="<?php xcho($search['begin_last_follow_time']) ?>" name="begin_last_follow_time" class="form-control begin_last_follow_time" placeholder="yy-mm-dd">
                            <input size="16" type="text"  value="<?php xcho($search['end_last_follow_time']) ?>" name="end_last_follow_time" class="form-control end_last_follow_time"
                                   placeholder="yy-mm-dd">
                            <input type="submit" class="btn btn-primary edit" value="搜索" />
                        </div>
                    </div>
                    <div class="btns-group">
                        <button type="submit" class="btn btn-primary btn-sm">确定</button>
                    </div>
                </div>
            </div>
            <div class="class-box">
                <div class="class-box-head">
                    <div class="class-box-title">
                        <h3>藏经阁</h3>
                        <div class="class-box-tools">
<!--                                <li><span class="btn btn-primary stu_export">导出</span></li>-->
                        </div>
                    </div>
                    <div class="from-top row">
                        <div class="from-top-left col-md-5">
                            <ul>
                                <?php if (!empty($aActions['edit_tmk'])) { ?>
                                    <li>
                                        <button type="button" class="btn btn-primary" id="tmk">分配TMK</button>
                                    </li>
                                <?php } ?>
                                <?php if (!empty($aActions['getPool'])) { ?>
                                    <button type="button" class="btn btn-primary" id="have">批量领取</button>
                                <?php } ?>
                                <li class="dropdown">
                                    <button type="button" class="btn btn-warning dropdown-toggle"
                                            data-toggle="dropdown" href="#" role="button" aria-haspopup="true"
                                            aria-expanded="false">更多操作 <span class="caret"></span></button>
                                    <ul class="dropdown-menu">
                                        <?php if (!empty($aActions['edits'])) { ?>
                                            <li><a href="#" id="updates">批量修改</a></li>
                                        <?php } ?>
                                        <?php if (!empty($aActions['dels'])) { ?>
                                            <li><a href="#" id="dels" class="delete">批量删除</a></li>
                                        <?php } ?>

                                    </ul>
                                </li>

                            </ul>
                        </div>
                    </div>
                </div>
                <div class="class-box-body">
                    <table class="layui-form table table-bordered table-hover table table-bordered table-striped table-fixed">
                        <thead>
                        <tr>
                            <th>
                                <div id="checkAll"><input lay-filter="allChoose" type="checkbox" lay-skin="primary" name="checkAll"></div>
                            </th>
                            <th>名称</th>
                            <th>联系手机</th>
                            <th>意向状态</th>
                            <th style="cursor: pointer;">
                                <a style="position: relative;"  href="javascript:;">
                                    最新跟踪时间
                                    <span style="position: absolute; top:-6px" ><a href="<?php xcho($order_by_field['last_follow_time_asc']) ?>"><i class="upOrder glyphicon glyphicon-triangle-top" style="display:"></i></a>
                                           <a href="<?php xcho($order_by_field['last_follow_time_desc']) ?>"><i class="dropOrder glyphicon glyphicon-triangle-bottom"style="display:
                                       "></i></a>
                                    </span>
                            </th>
                            <th width="150px">最新跟踪记录</th>
                            <th>最新追踪结果</th>
                            <th>TMK负责人</th>
                            <th>CC负责人</th>
                            <th>渠道来源</th>
                            <th style="cursor: pointer;">
                                <a style="position: relative;"  href="javascript:;">
                                    下次联系时间
                                    <span style="position: absolute; top:-6px" ><a href="<?php xcho($order_by_field['next_contact_time_asc']) ?>"><i class="upOrder glyphicon glyphicon-triangle-top" style="display:"></i></a>
                                           <a href="<?php xcho($order_by_field['next_contact_time_desc']) ?>"><i class="dropOrder glyphicon glyphicon-triangle-bottom"style="display:
                                       "></i></a>
                                    </span>
                            </th>
                            <th style="cursor: pointer;">
                                <a style="position: relative;"  href="javascript:;">
                                    创建时间
                                    <span style="position: absolute; top:-6px" ><a href="<?php xcho($order_by_field['add_time_asc']) ?>"><i class="upOrder glyphicon glyphicon-triangle-top" style="display:"></i></a>
                                           <a href="<?php xcho($order_by_field['add_time_desc']) ?>"><i class="dropOrder glyphicon glyphicon-triangle-bottom"style="display:
                                       "></i></a>
                                    </span>
                            </th>
                            <th width="120px">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php foreach ($list as $vo) { ?>
                            <tr>
                                <td>
                                    <input lay-filter="itemChoose" value="<?php xcho($vo['id']) ?>" type="checkbox"
                                           name="ck" lay-skin="primary">
                                </td>
                                <td>
                                    <a href="<?php xcho(url('student/pool/studentinfo')) ?>?student_id=<?php xcho($vo['id']) ?>" target="_blank"><?php xcho($vo['sname']) ?></a>
                                </td>
                                <td><?php xcho($vo['cellphone']) ?></td>
                                <td><?php xcho($vo['intention_name']) ?></td>
                                <td><?php xcho($vo['new_add_time']) ?></td>
                                <td><?php xcho($vo['new_follow_remark']) ?></td>
                                <td><?php xcho($vo['new_contact_result_name']) ?></td>
                                <td><?php xcho($vo['tmk_name']) ?></td>
                                <td><?php xcho($vo['cc_name']) ?></td>
                                <td><?php xcho($vo['channel_cn_name']) ?></td>
                                <td><?php xcho($vo['next_contact_time']) ?></td>
                                <td><?php xcho($vo['add_time_name']) ?></td>
                                <td class="tdrow">
                                    <?php if (!empty($aActions['edit'])) { ?>
                                        <button data-cn_id="<?php xcho($vo['id']) ?>" type="button"
                                                class="btn btn-primary edit"
                                                user_id="<?php xcho($vo['id']) ?>"><a
                                                    style="display: block;color: #ffffff"
                                                    href="<?php xcho($editstudent) ?>?student_id=<?php xcho($vo['id']) ?>">编辑</a>
                                        </button>
                                    <?php } ?>
                                    <?php if (!empty($aActions['del'])) { ?>
                                        <button data-cn_id="<?php xcho($vo['id']) ?>" type="button"
                                                class="btn btn-sub delete">删除
                                        </button>
                                    <?php } ?>

                                </td>
                            </tr>
                        <?php } ?>
                        </tbody>
                    </table>
                    <form method="post" action="<?php xcho(url('/student/pool/index')) ?>">
                        <div class="row pagination-wrap">
                            <div class="col-sm-6">
                                
                                <div class="pagination-group col-sm-12">
                                    <input class="form-control" type="number" min="1" max="<?php xcho($maxPage) ?>"
                                       name="pagelist" placeholder="请输入页码" value="<?php xcho($nowPage) ?>"/>
                                    <input class="btn btn-primary" type="submit" value="确定"/>
                                    <span>共搜索到<?php xcho($totalNum) ?>条记录</span>
                                </div>
                            </div>
                            <div class="col-sm-6">
                                <ul class="pagination">
                                    <?php xchoHtml($page->render()) ?>
                                </ul>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </form>
    </div>
</div>
<div class="modal fade" id="tmk-modal" tabindex="-1" role="dialog" aria-labelledby="modal-primary-label"
     style="z-index:9999;display: none;">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header state modal-primary">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">×</span></button>
                <h4 class="modal-title" id="modal-primary-label"><i class="fa fa-user"></i>选择负责人</h4>
            </div>
            <div class="form-group">
                <input class="form-control" id="tmklistinput" type="text">
            </div>
            <div class="modal-body ztree" id="tmklist">

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" id="suretmk" data-dismiss="modal">　保存</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="cc-modal" tabindex="-1" role="dialog" aria-labelledby="modal-primary-label"
     style="z-index:9999;display: none;">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header state modal-primary">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">×</span></button>
                <h4 class="modal-title" id="modal-primary-label"><i class="fa fa-user"></i>选择负责人</h4>
            </div>
            <div class="form-group">
                <input class="form-control" id="cclistinput" type="text">
            </div>
            <div class="modal-body ztree" id="cclist">

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" id="surecc" data-dismiss="modal">　保存</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>
<div id="modalbox"></div>
<div class="modal fade" id="info-modal-group" tabindex="-1" role="dialog" aria-labelledby="modal-info-label">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header state modal-info">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="modal-info-label"><i class="fa fa-info"></i></h4>
            </div>
            <div class="modal-body" style="min-height: 150px;">
                <ul id="treeDemo" class="ztree">
                </ul>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-info" id="sureGroup" data-dismiss="modal">确定</button>
                <button type="button" class="btn btn-default" id="returnGroup" data-dismiss="modal">返回</button>
            </div>
        </div>
    </div>
</div>
<div id="updatebox" style="display: none">
    <select name="quickedit_field" class="small" style="width: 100%" onchange="quick_edit_fieldchange(this)">
        <option>请选择</option>
        <option value="sname" relvalue="1">学员姓名</option>
        <option value="cellphone" relvalue="1">联系手机</option>
        <option value="telephone" relvalue="15">家庭座机</option>
        <option value="sex" relvalue="1">性别</option>
        <option value="age" relvalue="1">年龄</option>
        <option value="wechat" relvalue="1">微信</option>
        <option value="qq" relvalue="1">QQ</option>
        <option value="email" relvalue="1">邮箱</option>
        <option value="channel_id" relvalue="15">渠道来源</option>
        <option value="province" relvalue="11">省</option>
        <option value="city" relvalue="5">市</option>
        <option value="county" relvalue="1">区县</option>
        <option value="home_address" relvalue="1">家庭地址</option>
        <option value="admission_time" relvalue="15">入学时间</option>
        <option value="school" relvalue="15">当前学校</option>
        <option value="grade" relvalue="5">年级</option>
        <option value="intention" relvalue="1">意向状态</option>
        <option value="is_test" relvalue="1021">是否测试</option>
        <option value="is_treasure" relvalue="1022">是否丢入藏经阁</option>
        <option value="creator_id" relvalue="86">创建人id</option>
        <option value="twx_id" relvalue="1033">天王星学员id</option>
        <option value="gw_id" relvalue="1">官网学员id</option>
        <option value="gw_password" relvalue="1">官网学员密码</option>
        <option value="tmk_id" relvalue="15">TMKID</option>
        <option value="cc_id" relvalue="15">CCID</option>
    </select>
    <div class="up_area" style="width: 100%;margin-top: 20px;">
        <div id="quickedit_field0" style="display: none;">&nbsp;</div>
        <div id="quickedit_field_sname" uitype="1" style="display: none;">
            <input type="text" tabindex="1" name="quickedit_value_sname" id="sname" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_cellphone" uitype="1" style="display: none;">
            <input type="text" tabindex="12" name="quickedit_value_cellphone" id="cellphone" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_telephone" uitype="1" style="display: none;">
            <input type="text" tabindex="12" name="quickedit_value_telephone" id="telephone" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_sex" uitype="15" style="display: none;">
            <!-- uitype 111 added for noneditable existing picklist values - ahmed -->
            <select name="quickedit_value_sex" id="sex" tabindex="511111" class="small">
                <option value="无">
                    无
                </option>
                <option value="male">
                    男
                </option>
                <option value="female">
                    女
                </option>
            </select>
        </div>
        <div id="quickedit_field_age" uitype="1" style="display: none;">
            <input type="text" tabindex="12" name="quickedit_value_age" id="age" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_wechat" uitype="1" style="display: none;">
            <input type="text" tabindex="12" name="quickedit_value_wechat" id="wechat" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_qq" uitype="1" style="display: none;">
            <input type="text" tabindex="12" name="quickedit_value_qq" id="qq" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_email" uitype="1" style="display: none;">
            <input type="text" tabindex="12" name="quickedit_value_email" id="email" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_channel_id" uitype="15" style="display: none;">
            <!-- uitype 111 added for noneditable existing picklist values - ahmed -->
            <select name="quickedit_value_channel_id" id="channel_id" tabindex="211111" class="small">
                <?php foreach ($channel as $cV) { ?>
                    <option value="<?php xcho($cV['id']) ?>" <?php if ($search['channel_id'] == $cV['id']) { ?>  selected="selected" <?php } ?> > <?php xcho($cV['cn_name']) ?></option>
                <?php } ?>
            </select>
        </div>
        <div id="quickedit_field_province" uitype="1" style="display: none;">
            <input type="text" tabindex="13" name="quickedit_value_province" id="province" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_city" uitype="1" style="display: none;">
            <input type="text" tabindex="3" name="quickedit_value_city" id="city" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_county" uitype="1" style="display: none;">
            <input type="text" tabindex="14" name="quickedit_value_county" id="county" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_home_address" uitype="1" style="display: none;">
            <input type="text" tabindex="4" name="quickedit_value_home_address" id="home_address" value=""
                   class="detailedViewTextBox">


        </div>
        <div id="quickedit_field_admission_time" uitype="1" style="display: none;">
            <input type="text" tabindex="15" name="quickedit_value_admission_time" id="admission_time" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_school" uitype="11" style="display: none;">
            <input type="text" tabindex="16" name="quickedit_value_school" id="school" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_grade" uitype="5" style="display: none;">

            <input name="quickedit_value_grade" tabindex="6" id="jscal_field_grade" type="text"
                   style="border:1px solid #bababa;" size="11" maxlength="10" value="">
            <i class="icon-calendar pure-icon-bu crm-bu-style" onclick="displayCalendar('jscal_field_cf_865',this);"
               style="width:50px;height:50px;cursor:pointer;font-size:14px">
            </i>
        </div>
        <div id="quickedit_field_intention" uitype="1" style="display: none;">
            <input type="text" tabindex="17" name="quickedit_value_intention" id="intention" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_is_test" uitype="1" style="display: none;">
            <input type="text" tabindex="7" name="quickedit_value_is_test" id="is_test" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_is_treasure" uitype="15" style="display: none;">
            <!-- uitype 111 added for noneditable existing picklist values - ahmed -->
            <select name="quickedit_value_is_treasure" id="is_treasure" tabindex="1811111" class="small">
                <option value="no">
                    否
                </option>
                <option value="yes">
                    是
                </option>
            </select>
        </div>
        <div id="quickedit_field_creator_id" uitype="5" style="display: none;">
            <input name="quickedit_value_creator_id" tabindex="19" id="creator_id" type="text">
        </div>
        <div id="quickedit_field_twx_id" uitype="5" style="display: none;">
            <input name="quickedit_value_twx_id" tabindex="19" id="twx_id" type="text">
        </div>
        <div id="quickedit_field_gw_id" uitype="5" style="display: none;">
            <input name="quickedit_value_gw_id" tabindex="19" id="gw_id" type="text">
        </div>
        <div id="quickedit_field_tmk_id" uitype="5" style="display: none;">
            <input name="quickedit_value_tmk_id" tabindex="19" id="tmk_id" type="text">
        </div>
        <div id="quickedit_field_cc_id" uitype="5" style="display: none;">
            <input name="quickedit_value_cc_id" tabindex="19" id="cc_id" type="text">
        </div>
    </div>
</div>
<input type="hidden" name="stuExport" value="<?php xcho($stuExport) ?>"/>
<input type="hidden" name="del" value="<?php xcho($del) ?>"/>
<input type="hidden" name="dels" value="<?php xcho($dels) ?>"/>
<input type="hidden" name="groupList" value="<?php xcho($groupList) ?>">
<input type="hidden" name="tmklist" value="<?php xcho($tmkList) ?>">
<input type="hidden" name="cclist" value="<?php xcho($ccList) ?>">
<input type="hidden" name="editTMK" value="<?php xcho($editTMK) ?>">
<input type="hidden" name="get_pool" value="<?php xcho($getPool) ?>">
<input type="hidden" name="editCC" value="<?php xcho($editCC) ?>">
<input type="hidden" name="edit_student" value="<?php xcho($editstudent) ?>"/>
<input type="hidden" name="batch_student" value="<?php xcho($batchStudent) ?>"/>
<script src="<?php xcho(loadSource('/assets/plugins/jquery/jquery.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/layui/layui.all.js')) ?>" charset="utf-8"></script>
<script src="<?php xcho(loadSource('/assets/plugins/bootstrap/js/bootstrap.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/bootstrap/js/bootstrap-datetimepicker.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/bootstrap/js/bootstrap-datetimepicker.fr.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/bootstrap/js/bootstrap-datetimepicker.zh-CN.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets//plugins/ztree/js/jquery.ztree.core.js')) ?>"></script>
<script type="text/javascript"
        src="<?php xcho(loadSource('/assets//plugins/ztree/js/jquery.ztree.excheck.js')) ?>"></script>
<script type="text/javascript"
        src="<?php xcho(loadSource('/assets//plugins/ztree/js/jquery.ztree.exedit.js')) ?>"></script>
<script>

    $(function(){

        $("#toggle").click(function() {
            $(this).text($("#content").is(":hidden") ? "渠道收起" : "渠道展开");
            $("#content").slideToggle();
        });

        $('#top').addClass('fa fa-arrow-up').on('click', function(){
            $('body,html').animate({scrollTop:0},500);
        })

        $("#channelAll").click(function(){
            var ischecked = $(this).is(':checked');
            var child = $(".checkbox_channel").find('input[type=checkbox]');
            child.each(function(index, item){
                item.checked = ischecked;
            });
        });
    })

    var select_option, select_element;
    function quick_edit_fieldchange(element) {

        var e = "#quickedit_field_" + element.value;
        //console.log($(e).html());
        $("div[id*='quickedit_field_']").css("display", "none");
        $("#LAY_layuipro").find(e).fadeIn();
        select_option = element.value;
        select_element = e
    }
    (function ($) {
        var layer = layui.layer
            , form = layui.form, laydate = layui.laydate;
        //全选
        /*$('input[name="checkAll"]').click(function () {
            //alert(this.checked);
            if ($(this).is(':checked')) {
                $('input[name="ck"]').each(function () {
                    //此处如果用attr，会出现第三次失效的情况
                    $(this).prop("checked", true);
                });
            } else {
                $('input[name="ck"]').each(function () {
                    $(this).removeAttr("checked", false);
                });
            }
        });*/

        //全选
        layui.form.on('checkbox(allChoose)', function(data){
            var child = $(data.elem).parents('table').find('tbody input[type="checkbox"]');
            child.each(function(index, item){
                item.checked = data.elem.checked;
            });
            form.render('checkbox');
        });
        
        //日历
        $(".begin_edit_time").datetimepicker({
            format: "yyyy-mm-dd",
            todayHighlight: true,
            autoclose: true,
            language: 'zh-CN',
            startView: 2,
            minView: 2,
            maxView: 2
        });
        $(".end_edit_time").datetimepicker({
            format: "yyyy-mm-dd",
            todayHighlight: true,
            autoclose: true,
            language: 'zh-CN',
            startView: 2,
            minView: 2,
            maxView: 2
        });
        $(".begin_add_time").datetimepicker({
            format: "yyyy-mm-dd",
            todayHighlight: true,
            autoclose: true,
            language: 'zh-CN',
            startView: 2,
            minView: 2,
            maxView: 2
        });
        $(".end_add_time").datetimepicker({
            format: "yyyy-mm-dd",
            todayHighlight: true,
            autoclose: true,
            language: 'zh-CN',
            startView: 2,
            minView: 2,
            maxView: 2
        });
        $(".begin_last_follow_time").datetimepicker({
            format: "yyyy-mm-dd",
            todayHighlight: true,
            autoclose: true,
            language: 'zh-CN',
            startView: 2,
            minView: 2,
            maxView: 2
        });
        $(".end_last_follow_time").datetimepicker({
            format: "yyyy-mm-dd",
            todayHighlight: true,
            autoclose: true,
            language: 'zh-CN',
            startView: 2,
            minView: 2,
            maxView: 2
        });
        $(".begin_next_contact_time").datetimepicker({
            format: "yyyy-mm-dd",
            todayHighlight: true,
            autoclose: true,
            language: 'zh-CN',
            startView: 2,
            minView: 2,
            maxView: 2
        });
        $(".end_next_contact_time").datetimepicker({
            format: "yyyy-mm-dd",
            todayHighlight: true,
            autoclose: true,
            language: 'zh-CN',
            startView: 2,
            minView: 2,
            maxView: 2
        });
        $(".form-group>select").change(function () {
            var dataVal = $(this).val();
            var aDataInfo = getDates(dataVal);
            var sClassInfo = $(this).attr('name');
            if (sClassInfo == 'datetp') {
                $('.begin_edit_time').val(aDataInfo['sStartDate']);
                $('.end_edit_time').val(aDataInfo['sEndDate']);
            }
            if (sClassInfo == 'add_time') {
                $('.begin_add_time').val(aDataInfo['sStartDate']);
                $('.end_add_time').val(aDataInfo['sEndDate']);
            }
            if (sClassInfo == 'next_contact_time') {
                $('.begin_next_contact_time').val(aDataInfo['sStartDate']);
                $('.end_next_contact_time').val(aDataInfo['sEndDate']);
            }
            if (sClassInfo == 'last_follow_id') {
                $('.begin_last_follow_time').val(aDataInfo['sStartDate']);
                $('.end_last_follow_time').val(aDataInfo['sEndDate']);
            }

        });
//        $(".form-group>select").change(function(){
//            var dataVal = $(this).val();
//            if(dataVal == 'define'){
//                $(this).siblings("input").attr('disabled',false);
//            }else{
//                $(this).siblings("input").attr('disabled',true);
//                $(this).siblings("input").val("");
//                $(this).siblings("input").attr('placeholder','yy-mm-dd');
//            }
//        });

        $(".top_more").hover(function () {
            $(this).find("ul").show();
        }, function () {
            $(this).find("ul").hide();
        });
        $("#dels").on("click", function () {
            var ids = [];
            $('input[name="ck"]:checked').each(function () {
                ids.push($(this).val());
            });
            console.info(ids);
            if (ids.length == 0) {
                layer.alert("至少选择一项");
            } else {
                $.ajax({
                    url: $("input[name='dels']").val(),
                    data: {
                        ids: ids
                    },
                    type: 'post',
                    dataType: 'json',
                    success: function (data) {
                        console.log(data)
                        if (data.success == 1) {
                            layer.alert("删除成功！", function () {
                                location.reload();
                            });
                        } else {

                        }
                    },
                    complete: function () {
                    },
                    error: function () {

                    }
                });
            }

        });
        $("#pool").on("click", function () {
            var ids = [];
            $('input[name="ck"]:checked').each(function () {
                ids.push($(this).val());
            });
            console.info(ids);
            if (ids.length == 0) {
                layer.alert("至少选择一项");
            } else {
                $.ajax({
                    url: $("input[name='isTreasure']").val(),
                    data: {
                        ids: ids
                    },
                    type: 'post',
                    dataType: 'json',
                    success: function (data) {
                        console.log(data)
                        if (data.success == 1) {
                            layer.alert("操作成功！", function () {
                                location.reload();
                            });
                        } else {

                        }
                    },
                    complete: function () {
                    },
                    error: function () {

                    }
                });
            }

        });
        $("#updates").on("click", function () {
            var ids = [];
            $('input[name="ck"]:checked').each(function () {
                ids.push($(this).val());
            });
            console.info(ids);
            if (ids.length == 0) {
                layer.alert("至少选择一项");
            } else {
                layer.open({
                    type: 1
                    , title: false //不显示标题栏
                    , closeBtn: false
                    , area: '300px;'
                    , shade: 0.8
                    , id: 'LAY_layuipro' //设定一个id，防止重复弹出
                    , btn: ['保存', '取消']
                    , moveType: 1 //拖拽模式，0或者1
                    , content: '<div style="padding: 50px; line-height: 22px;  font-weight: 300;">' +
                    $("#updatebox").html() +
                    '</div>'
                    , success: function (layero) {
                        var select_data = {};
                        var btn = layero.find('.layui-layer-btn');
                        btn.css('text-align', 'center');
                        btn.find('.layui-layer-btn0').on("click", function () {
                            console.log("#" + select_option)
                            var a = ".layui-layer-content #" + select_option;
                            console.log($(a).val())
                            select_data[select_option] = $(a).val()
                            $.ajax({
                                url: $("input[name='batch_student']").val(),
                                data: {
                                    ids: ids,
                                    data: select_data
                                },
                                type: 'post',
                                dataType: 'json',
                                success: function (data) {
                                    console.log(data)
                                    if (data.success == 1) {
                                        layer.alert("修改成功！", function () {
                                            console.log("!!!!!!")
                                            location.reload();
                                        });
                                    } else {

                                    }
                                },
                                complete: function () {
                                },
                                error: function () {

                                }
                            });
                        })
                    }
                });
            }

        });
        $("#tmk").on("click", function () {
            var ids = [];
            $('input[name="ck"]:checked').each(function () {
                ids.push($(this).val());
            });
            console.info(ids);
            if (ids.length == 0) {
                layer.alert("至少选择一项");
            } else {
                var modal = '<div class="modal fade" id="data-modal" tabindex="1" role="dialog" aria-labelledby="modal-info-label">' +
                    ' <div class="modal-dialog" role="document">' +
                    ' <div class="modal-content">' +
                    '<div class="modal-header state modal-info">' +
                    '<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>' +
                    '</button>' +
                    '<h4 class="modal-title" id="modal-info-label"><i class="fa fa-info"></i></h4>' +
                    '</div>' +
                    ' <div class="modal-body" style="min-height: 150px;">' +
                    '<div class="col-xs-12">' +
                    ' <label class="col-sm-3 control-label" style="line-height: 34px;text-align: right">TMK:</label>' +
                    '<div class="col-sm-9">' +
                    '<input class="form-control" data-tmk-id="" id="select-picker" name="select-picker" type="text" placeholder="TMK">' +
                    '</div>' +
                    '</div>' +
                    '</div>' +
                    '<div class="modal-footer">' +
                    '<button type="button" class="btn btn-info" id="surepass" data-dismiss="modal">保存</button>' +
                    '<button type="button" class="btn btn-default" id="returnGroup" data-dismiss="modal">返回</button>' +
                    '</div>' +
                    '</div>' +
                    '</div>' +
                    '</div>';
                $("#modalbox").html("").html(modal);
                $('#data-modal').modal({
                    keyboard: false,
                    backdrop: false
                });
                $("#select-picker").focus(function () {
                    $('#tmk-modal').modal({
                        keyboard: false,
                        backdrop: false
                    });
                });
                $("#suretmk").on("click", function () {
                    var zTree = $.fn.zTree.getZTreeObj("tmklist"),
                        nodes = zTree.getSelectedNodes(),
                        treeNode = nodes[0];
                    console.log(treeNode);
                    if (nodes.length == 0) {
                        alert("请先选择一个节点");
                        return;
                    }
                    $("#select-picker").val(treeNode.name).attr("data-tmk-id", treeNode.id);
                })
                $("#surepass").on("click", function () {
                    $.ajax({
                        url: $("input[name='editTMK']").val(),
                        type: 'post',
                        data: {
                            student_ids: ids,
                            tmk_id: $("input[name='select-picker']").attr("data-tmk-id")
                        },
                        dataType: 'json',
                        success: function (data) {
                            console.log(data);
                            if (data.success == 1) {
                                console.log("!!!!!!")
                                location.reload();
                            } else {
                            }
                        },
                        complete: function () {
                        },
                        error: function () {

                        }
                    });
                })
            }
        })
        $("#cc").on("click", function () {
            var ids = [];
            $('input[name="ck"]:checked').each(function () {
                ids.push($(this).val());
            });
            console.info(ids);
            if (ids.length == 0) {
                layer.alert("至少选择一项");
            } else {
                var modal = '<div class="modal fade" id="data-modal" tabindex="1" role="dialog" aria-labelledby="modal-info-label">' +
                    ' <div class="modal-dialog" role="document">' +
                    ' <div class="modal-content">' +
                    '<div class="modal-header state modal-info">' +
                    '<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>' +
                    '</button>' +
                    '<h4 class="modal-title" id="modal-info-label"><i class="fa fa-info"></i></h4>' +
                    '</div>' +
                    ' <div class="modal-body" style="min-height: 150px;">' +
                    '<div class="col-xs-12">' +
                    ' <label class="col-sm-3 control-label" style="line-height: 34px;text-align: right">CC:</label>' +
                    '<div class="col-sm-9">' +
                    '<input class="form-control" id="select-picker" name="select-picker" type="text" placeholder="CC">' +
                    '</div>' +
                    '</div>' +
                    '</div>' +
                    '<div class="modal-footer">' +
                    '<button type="button" class="btn btn-info" id="savecc" data-dismiss="modal">保存</button>' +
                    '<button type="button" class="btn btn-default" id="returncc" data-dismiss="modal">返回</button>' +
                    '</div>' +
                    '</div>' +
                    '</div>' +
                    '</div>';
                $("#modalbox").html("").html(modal);
                $('#data-modal').modal({
                    keyboard: false,
                    backdrop: false
                });
                $("#select-picker").focus(function () {
                    $('#cc-modal').modal({
                        keyboard: false,
                        backdrop: false
                    });
                });
                $("#surecc").on("click", function () {
                    var zTree = $.fn.zTree.getZTreeObj("cclist"),
                        nodes = zTree.getSelectedNodes(),
                        treeNode = nodes[0];
                    console.log(treeNode);
                    if (nodes.length == 0) {
                        alert("请先选择一个节点");
                        return;
                    }
                    $("#select-picker").val(treeNode.name).attr("data-cc-id", treeNode.id);
                })
                $("#savecc").on("click", function () {
                    console.log($("input[name='editCC']").val())
                    $.ajax({
                        url: $("input[name='editCC']").val(),
                        type: 'post',
                        data: {
                            student_ids: ids,
                            cc_id: $("input[name='select-picker']").attr("data-cc-id")
                        },
                        dataType: 'json',
                        success: function (data) {
                            if (data.success == 1) {
                                console.log("!!!!!!")
                                location.reload();
                            } else {
                            }
                        },
                        complete: function () {
                        },
                        error: function () {

                        }
                    });
                })
            }
        })
        $("#add").on("click", function () {
            var url = $("input[name='add_student']").val();
            window.location.href = url;
            //window.parent.addParentTab({href: $("input[name='add_student']").val(), title: '添加学员'})
        })
        $(".delete").on("click", function () {
            if (confirm("确定删除本条数据吗？")) {
                var cn_id = $(this).attr("data-cn_id");
                $.ajax({
                    url: $("input[name='del']").val(),
                    data: {
                        ids: cn_id
                    },
                    type: 'post',
                    dataType: 'json',
                    success: function (data) {
                        console.log(data)
                        if (data.success == 1) {
                            layer.alert("删除成功!", {
                                skin: 'layui-layer-molv'
                            }, function () {
                                location.reload();
                            })
                        } else {
                            layer.alert(data.msg, {
                                skin: 'layui-layer-molv'
                            }, function () {
                                location.reload();
                            })
                        }
                    },
                    complete: function () {
                    },
                    error: function () {

                    }
                });
            }
        })

        function getTmkListData() {
            var data_list;
            $.ajax({
                url: $("input[name='tmklist']").val(),
                type: 'post',
                async: false,
                dataType: 'json',
                success: function (data) {
                    console.log(data)
                    if (data.success == 1) {
                        data_list = data.data_list;
                    } else {
                    }
                },
                complete: function () {
                },
                error: function () {

                }
            });
            return data_list;
        }

        function getCcListData() {
            var data_list;
            $.ajax({
                url: $("input[name='cclist']").val(),
                type: 'post',
                async: false,
                dataType: 'json',
                success: function (data) {
                    if (data.success == 1) {
                        data_list = data.data_list;
                    } else {
                    }
                },
                complete: function () {
                },
                error: function () {

                }
            });
            return data_list;
        }

        $(".group-picker").focus(function () {
            $('#info-modal-group').modal({
                keyboard: false,
                backdrop: false
            });
            $('#info-modal-group').on('shown.bs.modal', function (e) {
                // 关键代码，如没将modal设置为 block，则$modala_dialog.height() 为零
                $(this).css('display', 'block');
                $(this).find('.modal-dialog').css({
                    'margin-top': "100px"
                });
            });
        });
        //查看范围
        var setting = {
            view: {
                selectedMulti: false
            },
            edit: {
                enable: false
            },
            data: {
                keep: {
                    parent: true,
                    leaf: true
                },
                simpleData: {
                    enable: true
                }
            },
            callback: {
                beforeDrag: beforeDrag,
//                beforeRemove: beforeRemove,
//          beforeRename: beforeRename,
//                onRemove: onRemove,
                onClick: zTreeOnClick
            }
        };
        var settingGroup = {
            view: {
                selectedMulti: false
            },
            edit: {
                enable: false
            },
            data: {
                keep: {
                    parent: true,
                    leaf: true
                },
                simpleData: {
                    enable: true
                }
            }
        };
        var log, className = "dark";

        function beforeDrag(treeId, treeNodes) {
            return false;
        }

        //选中赋值到input中
        function zTreeOnClick(event, treeId, treeNode) {
            console.log(treeNode);
            $(".group-picker").val(treeNode.name);
            $("#scale_type").val(treeNode.scale_type);
            $("#scale_id").val(treeNode.id);
        }

        $(document).ready(function () {
            onLoadZTree();
        });
        function onLoadZTree() {
            var treeNodes;
            $.ajax({
                url: $(".group-picker").attr('url'),
                type: 'get',
                async: false,
                dataType: 'json',
                success: function (data) {
                    if ( !!data.data_list ) {
                        treeNodes = data.data_list.aGroup;
                    }
                    //console.log(data);
                    //请求成功后处理函数
                    //把后台封装好的简单Json格式赋给treeNodes

                }
            });
            var t = $("#treeDemo");
            t = $.fn.zTree.init(t, setting, treeNodes);
        }

        $("form").submit(function (e) {
            //alert("Submitted");
        });
        var settingTmk = {
            view: {
                selectedMulti: false
            },
            edit: {
                enable: false
            },
            data: {
                keep: {
                    parent: true,
                    leaf: true
                },
                simpleData: {
                    enable: true
                }
            }
        };
        var zNodesTmk = getTmkListData();
        $.each(zNodesTmk, function (i, item) {
//            item.isParent = true;
            item.name = item.full_name
//            item.Pid = item.id
        })
        $.fn.zTree.init($("#tmklist"), settingTmk, zNodesTmk);


        $('#tmklistinput').on('input', function(){
            // 过滤数组
            var _filterList = getCurIndex(zNodesTmk, 'name', $(this).val())
            $.fn.zTree.init($("#tmklist"), settingTmk, _filterList);
        })

        var settingCc = {
            view: {
                selectedMulti: false
            },
            edit: {
                enable: false
            },
            data: {
                keep: {
                    parent: true,
                    leaf: true
                },
                simpleData: {
                    enable: true
                }
            }
        };
        var zNodesCc = getCcListData();
        $.each(zNodesCc, function (i, item) {
//            item.isParent = true;
            item.name = item.full_name
        })
        $.fn.zTree.init($("#cclist"), settingCc, zNodesCc);
         $('#cclistinput').on('input', function(){
            // 过滤数组
            var _filterList = getCurIndex(zNodesCc, 'name', $(this).val())
            $.fn.zTree.init($("#cclist"), settingCc, _filterList);
        })

    })(jQuery);


    $('.stu_export').click(function () {
        var aIds = [];
        $("input[name='ck']:checked").each(function () {
            aIds.push($(this).val());
        });
        if (aIds == '' || aIds.length == 0) {
            layer.alert("至少选择一项");
        } else {
            var url = $("input[name='stuExport']").val();
            $.ajax({
                url: url,
                type: 'post',
                dataType: 'json',
                data: {ids: aIds},
                success: function (resp) {
                    if (resp.success == 1) {
                        window.open(resp.data);
                    } else {
                        layer.alert("导出失败");
                    }
                },
                complete: function () {
                },
                error: function () {

                }
            });
        }

    });


    $("#have").on("click", function () {
        var ids = [];
        $('input[name="ck"]:checked').each(function () {
            ids.push($(this).val());
        });
        if (ids.length == 0) {
            layer.alert("至少选择一项");
        } else {
            if (confirm("确定领取该学员吗？")) {
                $.ajax({
                    url: $("input[name='get_pool']").val(),
                    data: {
                        ids: ids
                    },
                    type: 'post',
                    dataType: 'json',
                    success: function (data) {
                        console.log(data)
                        if (data.success == 1) {
                            layer.alert("操作成功！", function () {
                                location.reload();
                            });
                        } else {
                        }
                    },
                    complete: function () {
                    },
                    error: function () {
                    }

                });
            }
        }
    });




    function getDates(sDateType) {
        var aDate = new Array();
        aDate['sStartDate'] = '';
        aDate['sEndDate'] = '';
        switch (sDateType) {
            case 'month':
                aDate['sStartDate'] = '<?php $BeginDate = date("Y-m-01", strtotime(date("Y-m-d"))); xcho($BeginDate)?>';
                aDate['sEndDate'] = '<?php xcho(date("Y-m-d", strtotime("$BeginDate +1 month -1 day")))?>';
                break;
            case 'sevenday':
                aDate['sStartDate'] = '<?php xcho(date("Y-m-d", strtotime("-7 days")))?>';
                aDate['sEndDate'] = '<?php xcho(date("Y-m-d", strtotime("-1 days")))?>';
                break;
            case 'thirtyday':
                aDate['sStartDate'] = '<?php xcho(date("Y-m-d", strtotime("-30 days")))?>';
                aDate['sEndDate'] = '<?php xcho(date("Y-m-d", strtotime("-1 days")))?>';
                break;
            case 'today':
                aDate['sStartDate'] = '<?php xcho(date("Y-m-d"))?>';
                aDate['sEndDate'] = '<?php xcho(date("Y-m-d"))?>';
                break;
            case 'week':
                aDate['sStartDate'] = '<?php xcho(date("Y-m-d", strtotime("this week")))?>';
                aDate['sEndDate'] = '<?php xcho(date("Y-m-d", strtotime("this week +6 day")))?>';
                break;
            case 'yesterday':
                aDate['sStartDate'] = '<?php xcho(date("Y-m-d", strtotime("-1 days")))?>';
                aDate['sEndDate'] = '<?php xcho(date("Y-m-d", strtotime("-1 days")))?>';
                break;
            default:

                break;
        }
        return aDate;
    }

</script>
<?php include_once TPL_PATH . 'public/foot_script.phtml'; ?>
<button id="top" style="height: 50px;width: 50px;"></button></body>
</html>
